package com.petsbang.action;



import java.io.IOException;

import com.petsbang.imagezoom.ImageViewTouchAction;
import com.petsbang.utils.FileTools;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class ImageZoomActivity extends Activity {
	
	private ImageViewTouchAction	mImageView;
	
	@Override
	protected void onCreate( Bundle savedInstanceState )
	{
		super.onCreate( savedInstanceState );
		
		requestWindowFeature( Window.FEATURE_NO_TITLE );
		setContentView( R.layout.gallery_imagezoom_activity );
		getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN );
		
		Intent intent = this.getIntent();
		Bundle bundle = intent.getExtras();
		String imageUrl = bundle.getString("imageUrl");
		
		selectRandomImage(imageUrl);
	}
	
	@Override
	public void onContentChanged()
	{
		super.onContentChanged();
		mImageView = (ImageViewTouchAction)findViewById( R.id.imageViewTouch );
	}
	
	/**
	 * pick a random image from your library
	 * and display it
	 */
	public void selectRandomImage(String imageUrl)
	{
		Bitmap bitmap;
		try {
			bitmap = FileTools.readPicFile(imageUrl);
			mImageView.setImageBitmapReset(bitmap, 0, true);
		} catch (IOException e) {
			Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
		}

		return;
	}
}
	

